$('#regBtn').click(function () {

    var username = $.trim($("#username").val());
    var email = $.trim($("#email").val());
    var password = $.trim($("#password").val());
    var repassword = $.trim($("#repassword").val());
    var code = $.trim($("#code").val());
    var loginTips = $('#loginTips');
    if(username == null || username == '') {
        loginTips.show();
        loginTips.text('用户名不能为空！');
        return false;
    }
    if(email == null || email == '') {
        loginTips.show();
        loginTips.text('登录邮箱不能为空！');
        return false;
    }
    if(!isEmail(email)) {
        loginTips.show();
        loginTips.text('邮箱格式错误！');
        return false;
    }
    if(password == null || password == '') {
        loginTips.show();
        loginTips.text('请设置您的登录密码！');
        return false;
    }
    if(repassword == null || repassword == '') {
        loginTips.show();
        loginTips.text('重复密码不能为空！');
        return false;
    }
    if(password != repassword) {
        loginTips.show();
        loginTips.text('两次密码输入不一致！');
        return false;
    }
    if(code == null || code == '') {
        loginTips.show();
        loginTips.text('验证码不能为空！');
        return false;
    }
    loginTips.text('');
    loginTips.hide();

    var param = {username:username,email:email,password:password,repassword:repassword,code:code}

    $.ajax({
        url:"registerSubmit",
        type:"post",
        data:param,
        success:function(data){
            loginTips.show();
            loginTips.text(data.msg);
        }
    });
})
$('#getCode').click(function () {
    var loginTips = $('#loginTips');
    var email = $("#email").val();
    if(email == null || email == '') {
        loginTips.show();
        loginTips.text('登录邮箱不能为空！');
        return false;
    }
    if(!isEmail(email)) {
        loginTips.show();
        loginTips.text('邮箱格式错误！');
        return false;
    }
    $.ajax({
        url:"getCode",
        type:"post",
        data:{email:email},
        success:function(data){
            if(data == 0) {
                loginTips.show();
                loginTips.text('验证码已发送至邮箱'+email);
                settime($('#getCode'));
            }
            else {
                loginTips.show();
                loginTips.text('验证码发送失败');
            }
        },
        error:function(e){
            alert("错误！！");
            window.clearInterval(timer);
        }
    });
})
